package innerclass;
//创建一个老师类去实现回调类
public class Teacher implements CallBack {
    private Student student;
    public Teacher(Student student) {
        this.student=student;
    }
    public void askQuestion(){
     student.resolveAnswer(this);
    }
    public void tellAnswer(int answer){
        System.out.println("知道了，你的答案是"+answer);
    }
}


class HaoYiMing implements Student{
    @Override
    public void resolveAnswer(CallBack callBack) {
        try {
            Thread.sleep(3000);
        } catch (InterruptedException e) {
            e.printStackTrace();
        }

        callBack.tellAnswer(3);
    }


    public static void main(String[] args) {
        Student student=new HaoYiMing();
        Teacher teacher=new Teacher(student);
        teacher.askQuestion();

    }
}

